import socket
import ssl

client = ssl.wrap_socket(socket.socket())
client.connect(("api.xdclass.net", 443))
client.send("""GET /pub/api/v1/study_line/list?size=8\r\nHTTP/1.1\r\nHost: api.xdclass.net\r\nConnection: keep-alive\r\nsec-ch-ua: "Google Chrome";v="87", " Not;A Brand";v="99", "Chromium";v="87"
\r\nAccept: application/json, text/plain, */*\r\nsec-ch-ua-mobile: ?0\r\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36\r\nOrigin: https://xdclass.net\r\nSec-Fetch-Site: same-site\r\nSec-Fetch-Mode: cors\r\nSec-Fetch-Dest: empty\r\nReferer: https://xdclass.net/\r\nAccept-Encoding: gzip, deflate, br\r\nAccept-Language: zh-CN,zh;q=0.9""".encode("utf-8"))

buffer = []


while True:
    recv = client.recv(1024)
    if recv:
        buffer.append(recv)
    else:
        break

result = b''.join(buffer)
client.close()

print(result.decode("utf-8"))
